package com.shuorikeji.huohuo.ui.sj;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bytedance.sdk.djx.DJXSdk;
import com.bytedance.sdk.djx.IDJXService;
import com.bytedance.sdk.djx.model.DJXDrama;
import com.bytedance.sdk.djx.model.DJXError;
import com.bytedance.sdk.djx.model.DJXOthers;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.header.ClassicsHeader;
import com.scwang.smartrefresh.layout.listener.OnLoadMoreListener;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
import com.shuorikeji.huohuo.R;
import com.shuorikeji.huohuo.adapter.BookReadHisAdapter;
import com.shuorikeji.huohuo.adapter.BookSjAdapter;
import com.shuorikeji.huohuo.adapter.DjSeeHisAdapter;
import com.shuorikeji.huohuo.adapter.DjSjAdapter;
import com.shuorikeji.huohuo.adapter.MhReadHisAdapter;
import com.shuorikeji.huohuo.adapter.MhSdAdapter;
import com.shuorikeji.huohuo.adapter.MhSjAdapter;
import com.shuorikeji.huohuo.adapter.ScMhSdAdapter;
import com.shuorikeji.huohuo.base.BasePresenterActivity;
import com.shuorikeji.huohuo.bean.BookReadHisMainBean;
import com.shuorikeji.huohuo.bean.BookReadHisSSubBean;
import com.shuorikeji.huohuo.bean.BookSjMainBean;
import com.shuorikeji.huohuo.bean.BookSjSSubBean;
import com.shuorikeji.huohuo.bean.DjHisInfoBean;
import com.shuorikeji.huohuo.bean.DjSjInfoBean;
import com.shuorikeji.huohuo.bean.DjSjMainBean;
import com.shuorikeji.huohuo.bean.MhReadHisMainBean;
import com.shuorikeji.huohuo.bean.MhReadHisSSubBean;
import com.shuorikeji.huohuo.bean.MhSdInfoBean;
import com.shuorikeji.huohuo.bean.MhSdMainBean;
import com.shuorikeji.huohuo.bean.MhSdScMainBean;
import com.shuorikeji.huohuo.bean.MhSdScSSubBean;
import com.shuorikeji.huohuo.bean.MhSjMainBean;
import com.shuorikeji.huohuo.bean.MhSjSSubBean;
import com.shuorikeji.huohuo.callback.ClickCallBack;
import com.shuorikeji.huohuo.mvp.AllPresenter;
import com.shuorikeji.huohuo.ui.SearchActivity;
import com.shuorikeji.huohuo.ui.dj.DjXqActivity;
import com.shuorikeji.huohuo.ui.fl.TaskGcActivity;
import com.shuorikeji.huohuo.ui.home.BookInfoActivity;
import com.shuorikeji.huohuo.ui.home.HomeActivity;
import com.shuorikeji.huohuo.ui.me.MyActivity;
import com.shuorikeji.huohuo.ui.mh.MhDetailActivity;
import com.shuorikeji.huohuo.utils.BusinessUtils;
import com.shuorikeji.huohuo.utils.JsonUtil;
import com.shuorikeji.huohuo.utils.SpacesItemDecoration;
import com.shuorikeji.huohuo.utils.ToastShowUtil;
import com.shuorikeji.huohuo.view.GridDividerItemDecoration;

import java.util.ArrayList;
import java.util.List;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import butterknife.BindView;

public class SjActivity extends BasePresenterActivity<AllPresenter> {
    @BindView(R.id.srl_layout_sj_book)
    SmartRefreshLayout srlSjBook;
    @BindView(R.id.rv_data_sj_book)
    RecyclerView rvSjBook;
    @BindView(R.id.ll_tab_1)
    LinearLayout llTab1;
    @BindView(R.id.ll_tab_2)
    LinearLayout llTab2;
    @BindView(R.id.ll_tab_3)
    LinearLayout llTab3;
    @BindView(R.id.ll_tab_4)
    LinearLayout llTab4;
    @BindView(R.id.ll_sj_tab)
    LinearLayout llSjTab;
    @BindView(R.id.tv_sj_tab)
    TextView tvSjTab;
    @BindView(R.id.iv_sj_tab)
    ImageView ivSjTab;
    @BindView(R.id.ll_ls_tab)
    LinearLayout llLsTab;
    @BindView(R.id.tv_ls_tab)
    TextView tvLsTab;
    @BindView(R.id.iv_ls_tab)
    ImageView ivLsTab;
    @BindView(R.id.ll_mh_sd_tab)
    LinearLayout llMhSdTab;
    @BindView(R.id.tv_mh_sd_tab)
    TextView tvMhSdTab;
    @BindView(R.id.iv_mh_sd_tab)
    ImageView ivMhSdTab;
    @BindView(R.id.iv_search)
    ImageView ivSearch;
    @BindView(R.id.ll_sj_ui)
    LinearLayout llSjUi;
    @BindView(R.id.tv_sj_book)
    TextView tvSjBook;
    @BindView(R.id.tv_sj_mh)
    TextView tvSjMh;
    @BindView(R.id.tv_sj_dj)
    TextView tvSjDj;
    @BindView(R.id.srl_layout_sj_mh)
    SmartRefreshLayout srlSjMh;
    @BindView(R.id.rv_data_sj_mh)
    RecyclerView rvSjMh;
    @BindView(R.id.srl_layout_sj_dj)
    SmartRefreshLayout srlSjDj;
    @BindView(R.id.rv_data_sj_dj)
    RecyclerView rvSjDj;
    @BindView(R.id.ll_ls_ui)
    LinearLayout llLsUi;
    @BindView(R.id.tv_ls_book)
    TextView tvLsBook;
    @BindView(R.id.tv_ls_mh)
    TextView tvLsMh;
    @BindView(R.id.tv_ls_dj)
    TextView tvLsDj;
    @BindView(R.id.srl_layout_ls_book)
    SmartRefreshLayout srlLsBook;
    @BindView(R.id.rv_data_ls_book)
    RecyclerView rvLsBook;
    @BindView(R.id.srl_layout_ls_mh)
    SmartRefreshLayout srlLsMh;
    @BindView(R.id.rv_data_ls_mh)
    RecyclerView rvLsMh;
    @BindView(R.id.srl_layout_ls_dj)
    SmartRefreshLayout srlLsDj;
    @BindView(R.id.rv_data_ls_dj)
    RecyclerView rvLsDj;
    @BindView(R.id.iv_xg)
    ImageView ivXg;
    @BindView(R.id.ll_bottom_1)
    LinearLayout llBottom1;
    @BindView(R.id.ll_add_sj)
    LinearLayout llAddSj;
    @BindView(R.id.ll_delete)
    LinearLayout llDelete;
    @BindView(R.id.rl_top)
    RelativeLayout rlTop;
    @BindView(R.id.rl_xg)
    RelativeLayout rlXg;
    @BindView(R.id.tv_qx)
    TextView tvQx;
    @BindView(R.id.tv_count)
    TextView tvCount;
    @BindView(R.id.tv_done)
    TextView tvDone;
    @BindView(R.id.ll_ls_sub_type_layout)
    LinearLayout llLsSubTypeLayout;
    @BindView(R.id.ll_mh_sd_ui)
    LinearLayout llMhSdUI;
    @BindView(R.id.tv_mh_sd_my_cj_tab)
    TextView tvMhSdCjTab;
    @BindView(R.id.tv_mh_sd_my_sc_tab)
    TextView tvMhSdScTab;
    @BindView(R.id.iv_mh_sd_cj)
    ImageView ivMhSdCj;
    @BindView(R.id.iv_mh_sd_xg)
    ImageView ivMhSdXg;
    @BindView(R.id.srl_layout_mh_sd)
    SmartRefreshLayout srlMhSd;
    @BindView(R.id.rv_data_mh_sd)
    RecyclerView rvMhSd;
    @BindView(R.id.srl_layout_sc_mh_sd)
    SmartRefreshLayout srlScMhSd;
    @BindView(R.id.rv_data_sc_mh_sd)
    RecyclerView rvScMhSd;

    private int topTypeTag;//1书架 2历史 3漫画书单
    private int sjSubTypeTag;//书架-1小说 2漫画 3追剧
    private int lsSubTypeTag;//历史-1小说 2漫画 3追剧
    private int mhSdSubTypeTag;//漫画书单-1我创建的 2我收藏的
    private int curBookSjPage;
    private List<BookSjSSubBean> bookSjList = new ArrayList<>();
    private BookSjAdapter bookSjAdapter;
    private int curMhSjPage;
    private List<MhSjSSubBean> mhSjList = new ArrayList<>();
    private MhSjAdapter mhSjAdapter;
    private int curZjSjPage;
    private List<DjSjInfoBean> djSjList = new ArrayList<>();
    private DjSjAdapter djSjAdapter;
    private int curBookReadHisPage;
    private List<BookReadHisSSubBean> bookReadHisList = new ArrayList<>();
    private BookReadHisAdapter bookReadHisAdapter;
    private int curMhReadHisPage;
    private List<MhReadHisSSubBean> mhReadHisList = new ArrayList<>();
    private MhReadHisAdapter mhReadHisAdapter;
    private int curDjSeeHisPage;
    private List<DJXDrama> djHisList = new ArrayList<>();
    private DjSeeHisAdapter djSeeHisAdapter;
    private int curCjMhSdPage;
    private List<MhSdInfoBean> cjMhSdList = new ArrayList<>();
    private MhSdAdapter cjMhSdAdapter;
    private int curScMhSdPage;
    private List<MhSdScSSubBean> scMhSdList = new ArrayList<>();
    private ScMhSdAdapter scMhSdAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getmImmersionBar().reset().statusBarColor(R.color.transparent).statusBarDarkFont(true, 0.2f).init();
    }

    @Override
    protected void setContentView() {
        setContentView(R.layout.activity_sj);
    }

    @Override
    protected void initData() {
        curBookSjPage = 1;
        curMhSjPage = 1;
        curZjSjPage = 1;
        curBookReadHisPage = 1;
        initSmartRefreshLayout();
        initAdapter();
        setTopTitle(1);
        setTopTab(1);
        setSjType(1);
        getBookSjList();
        initClick();
    }

    private void initSmartRefreshLayout() {
        srlSjBook.setRefreshHeader(new ClassicsHeader(SjActivity.this));
        srlSjBook.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh(RefreshLayout refreshLayout) {
                //刷新
                curBookSjPage = 1;
                getBookSjList();
            }
        });
        srlSjBook.setOnLoadMoreListener(new OnLoadMoreListener() {
            @Override
            public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
                //加载更多
                curBookSjPage = curBookSjPage + 1;
                getBookSjList();
            }
        });

        srlSjMh.setRefreshHeader(new ClassicsHeader(SjActivity.this));
        srlSjMh.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh(RefreshLayout refreshLayout) {
                //刷新
                curMhSjPage = 1;
                getMhSjList();
            }
        });
        srlSjMh.setOnLoadMoreListener(new OnLoadMoreListener() {
            @Override
            public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
                //加载更多
                curMhSjPage = curMhSjPage + 1;
                getMhSjList();
            }
        });

        srlSjDj.setRefreshHeader(new ClassicsHeader(SjActivity.this));
        srlSjDj.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh(RefreshLayout refreshLayout) {
                //刷新
                curZjSjPage = 1;
                getZjSjList();
            }
        });
        srlSjDj.setOnLoadMoreListener(new OnLoadMoreListener() {
            @Override
            public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
                //加载更多
                curZjSjPage = curZjSjPage + 1;
                getZjSjList();
            }
        });

        srlLsBook.setRefreshHeader(new ClassicsHeader(SjActivity.this));
        srlLsBook.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh(RefreshLayout refreshLayout) {
                //刷新
                curBookReadHisPage = 1;
                getBookReadHis();
            }
        });
        srlLsBook.setOnLoadMoreListener(new OnLoadMoreListener() {
            @Override
            public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
                //加载更多
                curBookReadHisPage = curBookReadHisPage + 1;
                getBookReadHis();
            }
        });

        srlLsMh.setRefreshHeader(new ClassicsHeader(SjActivity.this));
        srlLsMh.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh(RefreshLayout refreshLayout) {
                //刷新
                curMhReadHisPage = 1;
                getMhReadHis();
            }
        });
        srlLsMh.setOnLoadMoreListener(new OnLoadMoreListener() {
            @Override
            public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
                //加载更多
                curMhReadHisPage = curMhReadHisPage + 1;
                getMhReadHis();
            }
        });

        srlLsDj.setRefreshHeader(new ClassicsHeader(SjActivity.this));
        srlLsDj.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh(RefreshLayout refreshLayout) {
                //刷新
                curDjSeeHisPage = 1;
                getDjSeeHis();
            }
        });
        srlLsDj.setOnLoadMoreListener(new OnLoadMoreListener() {
            @Override
            public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
                //加载更多
                curDjSeeHisPage = curDjSeeHisPage + 1;
                getDjSeeHis();
            }
        });

        srlMhSd.setRefreshHeader(new ClassicsHeader(SjActivity.this));
        srlMhSd.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh(RefreshLayout refreshLayout) {
                //刷新
                curCjMhSdPage = 1;
                getCjMhSd();
            }
        });
        srlMhSd.setOnLoadMoreListener(new OnLoadMoreListener() {
            @Override
            public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
                //加载更多
                curCjMhSdPage = curCjMhSdPage + 1;
                getCjMhSd();
            }
        });

        srlScMhSd.setRefreshHeader(new ClassicsHeader(SjActivity.this));
        srlScMhSd.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh(RefreshLayout refreshLayout) {
                //刷新
                curScMhSdPage = 1;
                getScMhSd();
            }
        });
        srlScMhSd.setOnLoadMoreListener(new OnLoadMoreListener() {
            @Override
            public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
                //加载更多
                curScMhSdPage = curScMhSdPage + 1;
                getScMhSd();
            }
        });
    }

    private void initAdapter() {
        rvSjBook.setLayoutManager(new GridLayoutManager(this, 3, GridLayoutManager.VERTICAL, false));
        rvSjBook.addItemDecoration(new GridDividerItemDecoration(60));
        bookSjAdapter = new BookSjAdapter(SjActivity.this, new ClickCallBack() {
            @Override
            public void onClick(int flag, Object object) {
                switch (flag) {
                    case 1:
                        BookSjSSubBean data = (BookSjSSubBean) object;
                        if (data.getId() == -1) {
                            //查看更多
                            curBookReadHisPage = 1;
                            setTopTab(2);
                            setLsType(1);
                            getBookReadHis();
                        } else {
                            Intent intent = new Intent(SjActivity.this, BookInfoActivity.class);
                            intent.putExtra("BOOK_ID", data.getNovel_id());
                            startActivity(intent);
                        }
                        break;
                }
            }
        });
        rvSjBook.setAdapter(bookSjAdapter);

        rvSjMh.setLayoutManager(new GridLayoutManager(this, 3, GridLayoutManager.VERTICAL, false));
        rvSjMh.addItemDecoration(new GridDividerItemDecoration(60));
        mhSjAdapter = new MhSjAdapter(SjActivity.this, new ClickCallBack() {
            @Override
            public void onClick(int flag, Object object) {
                switch (flag) {
                    case 1:
                        MhSjSSubBean data = (MhSjSSubBean) object;
                        if (data.getId() == -1) {
                            curBookReadHisPage = 1;
                            setTopTab(2);
                            setLsType(1);
                            getBookReadHis();
                        } else {
                            Intent intent = new Intent(SjActivity.this, MhDetailActivity.class);
                            intent.putExtra("MH_ID", data.getCartoon_id());
                            startActivity(intent);
                        }
                        break;
                }
            }
        });
        rvSjMh.setAdapter(mhSjAdapter);

        rvSjDj.setLayoutManager(new GridLayoutManager(this, 3, GridLayoutManager.VERTICAL, false));
        rvSjDj.addItemDecoration(new GridDividerItemDecoration(60));
        djSjAdapter = new DjSjAdapter(SjActivity.this, new ClickCallBack() {
            @Override
            public void onClick(int flag, Object object) {
                switch (flag) {
                    case 1:
                        DjSjInfoBean data = (DjSjInfoBean) object;
                        if (data.getId() == -1) {
                            curBookReadHisPage = 1;
                            setTopTab(2);
                            setLsType(1);
                            getBookReadHis();
                        } else {
                            Intent intent = new Intent(SjActivity.this, DjXqActivity.class);
                            intent.putExtra("dramaId", data.getVid());
                            intent.putExtra("type", "1");
                            startActivity(intent);
                        }
                        break;
                }
            }
        });
        rvSjDj.setAdapter(djSjAdapter);

        rvLsBook.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
        rvLsBook.addItemDecoration(new SpacesItemDecoration(0, 0, 10, 0));
        bookReadHisAdapter = new BookReadHisAdapter(mContext, new ClickCallBack() {
            @Override
            public void onClick(int flag, Object object) {
                switch (flag) {
                    case 1:
                        BookReadHisSSubBean data1 = (BookReadHisSSubBean) object;
                        Intent intent = new Intent(SjActivity.this, BookInfoActivity.class);
                        intent.putExtra("BOOK_ID", data1.getNovel_id());
                        startActivity(intent);
                        break;
                    case 2:
                        BookReadHisSSubBean data = (BookReadHisSSubBean) object;
                        for (int i = 0; i < bookReadHisList.size(); i++) {
                            if (data.getId() == bookReadHisList.get(i).getId()) {
                                if (bookReadHisList.get(i).isSec()) {
                                    bookReadHisList.get(i).setSec(false);
                                } else {
                                    bookReadHisList.get(i).setSec(true);
                                }
                                break;
                            }
                        }
                        int secCount = 0;
                        for (int i = 0; i < bookReadHisList.size(); i++) {
                            if (bookReadHisList.get(i).isSec()) {
                                secCount = secCount + 1;
                            }
                        }
                        tvCount.setText("共选择" + secCount + "个");
                        bookReadHisAdapter.setData(bookReadHisList);
                        break;
                }
            }
        });
        rvLsBook.setAdapter(bookReadHisAdapter);

        rvLsMh.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
        rvLsMh.addItemDecoration(new SpacesItemDecoration(0, 0, 10, 0));
        mhReadHisAdapter = new MhReadHisAdapter(mContext, new ClickCallBack() {
            @Override
            public void onClick(int flag, Object object) {
                switch (flag) {
                    case 1:
                        MhReadHisSSubBean data1 = (MhReadHisSSubBean) object;
                        Intent intent = new Intent(SjActivity.this, MhDetailActivity.class);
                        intent.putExtra("MH_ID", data1.getCartoon_id());
                        startActivity(intent);
                        break;
                    case 2:
                        MhReadHisSSubBean data = (MhReadHisSSubBean) object;
                        for (int i = 0; i < mhReadHisList.size(); i++) {
                            if (data.getId() == mhReadHisList.get(i).getId()) {
                                if (mhReadHisList.get(i).isSec()) {
                                    mhReadHisList.get(i).setSec(false);
                                } else {
                                    mhReadHisList.get(i).setSec(true);
                                }
                                break;
                            }
                        }
                        int secCount = 0;
                        for (int i = 0; i < mhReadHisList.size(); i++) {
                            if (mhReadHisList.get(i).isSec()) {
                                secCount = secCount + 1;
                            }
                        }
                        tvCount.setText("共选择" + secCount + "个");
                        mhReadHisAdapter.setData(mhReadHisList);
                        break;
                }
            }
        });
        rvLsMh.setAdapter(mhReadHisAdapter);

        rvLsDj.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
        rvLsDj.addItemDecoration(new SpacesItemDecoration(0, 0, 10, 0));
        djSeeHisAdapter = new DjSeeHisAdapter(mContext, new ClickCallBack() {
            @Override
            public void onClick(int flag, Object object) {
                switch (flag) {
                    case 1:
                        DJXDrama data1 = (DJXDrama) object;
                        Intent intent = new Intent(SjActivity.this, DjXqActivity.class);
                        intent.putExtra("dramaId", data1.id);
                        intent.putExtra("dramaBean", JsonUtil.toJson(data1));
                        startActivity(intent);
                        break;
                    case 2:
                        DjHisInfoBean data = (DjHisInfoBean) object;
//                        for (int i = 0; i < djHisList.size(); i++) {
//                            if (data.getId() == djHisList.get(i).getId()) {
//                                if (djHisList.get(i).isSec()) {
//                                    djHisList.get(i).setSec(false);
//                                } else {
//                                    djHisList.get(i).setSec(true);
//                                }
//                                break;
//                            }
//                        }
//                        int secCount = 0;
//                        for (int i = 0; i < djHisList.size(); i++) {
//                            if (djHisList.get(i).isSec()) {
//                                secCount = secCount + 1;
//                            }
//                        }
                        //tvCount.setText("共选择" + secCount + "个");
                        djSeeHisAdapter.setData(djHisList);
                        break;
                }
            }
        });
        rvLsDj.setAdapter(djSeeHisAdapter);

        rvMhSd.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
        rvMhSd.addItemDecoration(new SpacesItemDecoration(0, 0, 10, 0));
        cjMhSdAdapter = new MhSdAdapter(mContext, new ClickCallBack() {
            @Override
            public void onClick(int flag, Object object) {
                switch (flag) {
                    case 1:
                        MhSdInfoBean data = (MhSdInfoBean) object;
                        Intent intent = new Intent(SjActivity.this, MhSdDetailActivity.class);
                        intent.putExtra("SD_ID", data.getId());
                        startActivity(intent);
                        break;
                    case 2:
                        //收藏
                        MhSdInfoBean scData = (MhSdInfoBean) object;
                        if (scData.getIs_collect() == 0) {
                            scMhSd(scData.getId());
                        } else {
                            qxScMhSd(scData.getId());
                        }
                        break;
                    case 3:
                        //点赞
                        MhSdInfoBean dzData = (MhSdInfoBean) object;
                        if (dzData.getIs_like() == 0) {
                            dzMhSd(dzData.getId());
                        } else {
                            qxDzMhSd(dzData.getId());
                        }
                        break;
                }
            }
        });
        rvMhSd.setAdapter(cjMhSdAdapter);

        rvScMhSd.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
        rvScMhSd.addItemDecoration(new SpacesItemDecoration(0, 0, 10, 0));
        scMhSdAdapter = new ScMhSdAdapter(mContext, new ClickCallBack() {
            @Override
            public void onClick(int flag, Object object) {
                switch (flag) {
                    case 1:
                        MhSdScSSubBean data = (MhSdScSSubBean) object;
                        Intent intent = new Intent(SjActivity.this, MhSdDetailActivity.class);
                        intent.putExtra("SD_ID", data.getBook_list_id());
                        startActivity(intent);
                        break;
                    case 2:
                        //收藏
                        MhSdScSSubBean scData = (MhSdScSSubBean) object;
                        if (scData.getIs_collect() == 0) {
                            scMhSd(scData.getBook_list_id());
                        } else {
                            qxScMhSd(scData.getBook_list_id());
                        }
                        break;
                    case 3:
                        //点赞
                        MhSdScSSubBean dzData = (MhSdScSSubBean) object;
                        if (dzData.getIs_like() == 0) {
                            dzMhSd(dzData.getBook_list_id());
                        } else {
                            qxDzMhSd(dzData.getBook_list_id());
                        }
                        break;
                }
            }
        });
        rvScMhSd.setAdapter(scMhSdAdapter);
    }

    /**
     * top title的显示
     *
     * @param flag 1 tab view
     *             2 修改 view
     */
    private void setTopTitle(int flag) {
        rlTop.setVisibility((flag == 1) ? View.VISIBLE : View.GONE);
        llLsSubTypeLayout.setVisibility((flag == 1) ? View.VISIBLE : View.GONE);
        rlXg.setVisibility((flag == 2) ? View.VISIBLE : View.GONE);
        llBottom1.setVisibility((flag == 2) ? View.VISIBLE : View.GONE);
    }

    /**
     * top tab
     *
     * @param flag 1书架
     *             2历史
     *             3漫画书单
     */
    private void setTopTab(int flag) {
        topTypeTag = flag;
        tvSjTab.setTextColor((flag == 1) ? getResources().getColor(R.color.color_333333) : getResources().getColor(R.color.color_999999));
        BusinessUtils.setTxtFold(tvSjTab, (flag == 1) ? true : false);
        ivSjTab.setVisibility((flag == 1) ? View.VISIBLE : View.INVISIBLE);
        llSjUi.setVisibility((flag == 1) ? View.VISIBLE : View.GONE);

        tvLsTab.setTextColor((flag == 2) ? getResources().getColor(R.color.color_333333) : getResources().getColor(R.color.color_999999));
        BusinessUtils.setTxtFold(tvLsTab, (flag == 2) ? true : false);
        ivLsTab.setVisibility((flag == 2) ? View.VISIBLE : View.INVISIBLE);
        llLsUi.setVisibility((flag == 2) ? View.VISIBLE : View.GONE);
        ivXg.setVisibility((flag == 2) ? View.VISIBLE : View.GONE);

        tvMhSdTab.setTextColor((flag == 3) ? getResources().getColor(R.color.color_333333) : getResources().getColor(R.color.color_999999));
        BusinessUtils.setTxtFold(tvMhSdTab, (flag == 3) ? true : false);
        ivMhSdTab.setVisibility((flag == 3) ? View.VISIBLE : View.INVISIBLE);
        llMhSdUI.setVisibility((flag == 3) ? View.VISIBLE : View.GONE);
    }

    /**
     * 书架tab下数据类型
     *
     * @param flag 1小说
     *             2漫画
     *             3追剧
     */
    private void setSjType(int flag) {
        sjSubTypeTag = flag;
        tvSjBook.setBackground((flag == 1) ? getResources().getDrawable(R.drawable.shape_8_f9e141) : getResources().getDrawable(R.drawable.shape_8_f4f4f4));
        BusinessUtils.setTxtFold(tvSjBook, (flag == 1) ? true : false);
        srlSjBook.setVisibility((flag == 1) ? View.VISIBLE : View.GONE);

        tvSjMh.setBackground((flag == 2) ? getResources().getDrawable(R.drawable.shape_8_f9e141) : getResources().getDrawable(R.drawable.shape_8_f4f4f4));
        BusinessUtils.setTxtFold(tvSjMh, (flag == 2) ? true : false);
        srlSjMh.setVisibility((flag == 2) ? View.VISIBLE : View.GONE);

        tvSjDj.setBackground((flag == 3) ? getResources().getDrawable(R.drawable.shape_8_f9e141) : getResources().getDrawable(R.drawable.shape_8_f4f4f4));
        BusinessUtils.setTxtFold(tvSjDj, (flag == 3) ? true : false);
        srlSjDj.setVisibility((flag == 3) ? View.VISIBLE : View.GONE);
    }

    private void setMhSdTab(int flag) {
        mhSdSubTypeTag = flag;
        tvMhSdCjTab.setBackground((flag == 1) ? getResources().getDrawable(R.drawable.shape_8_f9e141) : getResources().getDrawable(R.drawable.shape_8_f4f4f4));
        BusinessUtils.setTxtFold(tvMhSdCjTab, (flag == 1) ? true : false);
        srlMhSd.setVisibility((flag == 1) ? View.VISIBLE : View.GONE);

        tvMhSdScTab.setBackground((flag == 2) ? getResources().getDrawable(R.drawable.shape_8_f9e141) : getResources().getDrawable(R.drawable.shape_8_f4f4f4));
        BusinessUtils.setTxtFold(tvMhSdScTab, (flag == 2) ? true : false);
        srlScMhSd.setVisibility((flag == 2) ? View.VISIBLE : View.GONE);
    }

    /**
     * 历史tab下数据类型
     *
     * @param flag 1小说
     *             2漫画
     *             3追剧
     */
    private void setLsType(int flag) {
        lsSubTypeTag = flag;
        tvLsBook.setBackground((flag == 1) ? getResources().getDrawable(R.drawable.shape_8_f9e141) : getResources().getDrawable(R.drawable.shape_8_f4f4f4));
        BusinessUtils.setTxtFold(tvLsBook, (flag == 1) ? true : false);
        srlLsBook.setVisibility((flag == 1) ? View.VISIBLE : View.GONE);

        tvLsMh.setBackground((flag == 2) ? getResources().getDrawable(R.drawable.shape_8_f9e141) : getResources().getDrawable(R.drawable.shape_8_f4f4f4));
        BusinessUtils.setTxtFold(tvLsMh, (flag == 2) ? true : false);
        srlLsMh.setVisibility((flag == 2) ? View.VISIBLE : View.GONE);

        tvLsDj.setBackground((flag == 3) ? getResources().getDrawable(R.drawable.shape_8_f9e141) : getResources().getDrawable(R.drawable.shape_8_f4f4f4));
        BusinessUtils.setTxtFold(tvLsDj, (flag == 3) ? true : false);
        srlLsDj.setVisibility((flag == 3) ? View.VISIBLE : View.GONE);
    }

    private void scMhSd(int id) {
        mPresenter.scMhSd(true, id, new ClickCallBack() {
            @Override
            public void onClick(int flag, Object object) {
                switch (flag) {
                    case 1:
                        if (mhSdSubTypeTag == 1) {
                            for (int i = 0; i < cjMhSdList.size(); i++) {
                                if (id == cjMhSdList.get(i).getId()) {
                                    cjMhSdList.get(i).setCollect_num(cjMhSdList.get(i).getCollect_num() + 1);
                                    cjMhSdList.get(i).setIs_collect(1);
                                    break;
                                }
                            }
                            cjMhSdAdapter.setData(cjMhSdList);
                        } else if (mhSdSubTypeTag == 2) {
                            for (int i = 0; i < scMhSdList.size(); i++) {
                                if (id == scMhSdList.get(i).getId()) {
                                    scMhSdList.get(i).getBooklist().setCollect_num(scMhSdList.get(i).getBooklist().getCollect_num() + 1);
                                    scMhSdList.get(i).setIs_collect(1);
                                    break;
                                }
                            }
                            scMhSdAdapter.setData(scMhSdList);
                        }
                        break;
                    case 2:
                        String msg = (String) object;
                        ToastShowUtil.showToastCenter(SjActivity.this, msg);
                        break;
                }
            }
        });
    }

    private void qxScMhSd(int id) {
        mPresenter.qxScMhSd(true, id, new ClickCallBack() {
            @Override
            public void onClick(int flag, Object object) {
                switch (flag) {
                    case 1:
                        if (mhSdSubTypeTag == 1) {
                            for (int i = 0; i < cjMhSdList.size(); i++) {
                                if (id == cjMhSdList.get(i).getId()) {
                                    cjMhSdList.get(i).setCollect_num(cjMhSdList.get(i).getCollect_num() - 1);
                                    cjMhSdList.get(i).setIs_collect(0);
                                    break;
                                }
                            }
                            cjMhSdAdapter.setData(cjMhSdList);
                        } else if (mhSdSubTypeTag == 2) {
                            for (int i = 0; i < scMhSdList.size(); i++) {
                                if (id == scMhSdList.get(i).getId()) {
                                    scMhSdList.get(i).getBooklist().setCollect_num(scMhSdList.get(i).getBooklist().getCollect_num() - 1);
                                    scMhSdList.get(i).setIs_collect(0);
                                    break;
                                }
                            }
                            scMhSdAdapter.setData(scMhSdList);
                        }
                        break;
                    case 2:
                        String msg = (String) object;
                        ToastShowUtil.showToastCenter(SjActivity.this, msg);
                        break;
                }
            }
        });
    }

    private void dzMhSd(int id) {
        mPresenter.dzMhSd(true, id, new ClickCallBack() {
            @Override
            public void onClick(int flag, Object object) {
                switch (flag) {
                    case 1:
                        if (mhSdSubTypeTag == 1) {
                            for (int i = 0; i < cjMhSdList.size(); i++) {
                                if (id == cjMhSdList.get(i).getId()) {
                                    cjMhSdList.get(i).setLike_num(cjMhSdList.get(i).getLike_num() + 1);
                                    cjMhSdList.get(i).setIs_like(1);
                                    break;
                                }
                            }
                            cjMhSdAdapter.setData(cjMhSdList);
                        } else if (mhSdSubTypeTag == 2) {
                            for (int i = 0; i < scMhSdList.size(); i++) {
                                if (id == scMhSdList.get(i).getId()) {
                                    scMhSdList.get(i).getBooklist().setLike_num(scMhSdList.get(i).getBooklist().getLike_num() + 1);
                                    scMhSdList.get(i).setIs_like(1);
                                    break;
                                }
                            }
                            scMhSdAdapter.setData(scMhSdList);
                        }
                        break;
                    case 2:
                        String msg = (String) object;
                        ToastShowUtil.showToastCenter(SjActivity.this, msg);
                        break;
                }
            }
        });
    }

    private void qxDzMhSd(int id) {
        mPresenter.qxDzMhSd(true, id, new ClickCallBack() {
            @Override
            public void onClick(int flag, Object object) {
                switch (flag) {
                    case 1:
                        if (mhSdSubTypeTag == 1) {
                            for (int i = 0; i < cjMhSdList.size(); i++) {
                                if (id == cjMhSdList.get(i).getId()) {
                                    cjMhSdList.get(i).setLike_num(cjMhSdList.get(i).getLike_num() - 1);
                                    cjMhSdList.get(i).setIs_like(0);
                                    break;
                                }
                            }
                            cjMhSdAdapter.setData(cjMhSdList);
                        } else if (mhSdSubTypeTag == 2) {
                            for (int i = 0; i < scMhSdList.size(); i++) {
                                if (id == scMhSdList.get(i).getId()) {
                                    scMhSdList.get(i).getBooklist().setLike_num(scMhSdList.get(i).getBooklist().getLike_num() - 1);
                                    scMhSdList.get(i).setIs_like(0);
                                    break;
                                }
                            }
                            scMhSdAdapter.setData(scMhSdList);
                        }
                        break;
                    case 2:
                        String msg = (String) object;
                        ToastShowUtil.showToastCenter(SjActivity.this, msg);
                        break;
                }
            }
        });
    }

    private void getBookSjList() {
        mPresenter.bookSjList(true, 20, curBookSjPage, new ClickCallBack() {
            @Override
            public void onClick(int flag, Object object) {
                srlSjBook.finishLoadMore();
                srlSjBook.finishRefresh();
                switch (flag) {
                    case 1:
                        BookSjMainBean data = (BookSjMainBean) object;
                        if (curBookSjPage == 1) {
                            bookSjList.clear();
                        }
                        if (bookSjList != null && bookSjList.size() > 0) {
                            for (int i = bookSjList.size() - 1; i >= 0; i--) {
                                if (bookSjList.get(i).getId() == -1) {
                                    bookSjList.remove(i);
                                    break;
                                }
                            }
                        }
                        bookSjList.addAll(data.getData().getData());

                        BookSjSSubBean emptyData = new BookSjSSubBean();
                        emptyData.setId(-1);
                        bookSjList.add(emptyData);
                        emptyData = null;

                        bookSjAdapter.setData(bookSjList);
                        break;
                    case 2:
                        String msg = (String) object;
                        ToastShowUtil.showToastCenter(SjActivity.this, msg);
                        break;
                }
            }
        });
    }

    private void getMhSjList() {
        mPresenter.mhSjList(true, 20, curMhSjPage, new ClickCallBack() {
            @Override
            public void onClick(int flag, Object object) {
                srlSjMh.finishRefresh();
                srlSjMh.finishLoadMore();
                switch (flag) {
                    case 1:
                        MhSjMainBean data = (MhSjMainBean) object;
                        if (curMhSjPage == 1) {
                            mhSjList.clear();
                        }
                        if (mhSjList != null && mhSjList.size() > 0) {
                            for (int i = mhSjList.size() - 1; i >= 0; i--) {
                                if (mhSjList.get(i).getId() == -1) {
                                    mhSjList.remove(i);
                                    break;
                                }
                            }
                        }
                        mhSjList.addAll(data.getData().getData());

                        MhSjSSubBean emptyData = new MhSjSSubBean();
                        emptyData.setId(-1);
                        mhSjList.add(emptyData);
                        emptyData = null;

                        mhSjAdapter.setData(mhSjList);
                        break;
                    case 2:
                        String msg = (String) object;
                        ToastShowUtil.showToastCenter(SjActivity.this, msg);
                        break;
                }
            }
        });
    }

    private void getZjSjList() {
        mPresenter.zjJlList(true, 20, curZjSjPage, new ClickCallBack() {
            @Override
            public void onClick(int flag, Object object) {
                srlSjDj.finishLoadMore();
                srlSjDj.finishRefresh();
                switch (flag) {
                    case 1:
                        DjSjMainBean data = (DjSjMainBean) object;
                        if (curZjSjPage == 1) {
                            djSjList.clear();
                        }
                        if (djSjList != null && djSjList.size() > 0) {
                            for (int i = djSjList.size() - 1; i >= 0; i--) {
                                if (djSjList.get(i).getId() == -1) {
                                    djSjList.remove(i);
                                    break;
                                }
                            }
                        }
                        djSjList.addAll(data.getData().getData());

                        DjSjInfoBean emptyData = new DjSjInfoBean();
                        emptyData.setId(-1);
                        djSjList.add(emptyData);
                        emptyData = null;

                        djSjAdapter.setData(djSjList);
                        break;
                    case 2:
                        String msg = (String) object;
                        ToastShowUtil.showToastCenter(SjActivity.this, msg);
                        break;
                }
            }
        });
    }

    private void getBookReadHis() {
        mPresenter.bookReadHis(true, 20, curBookReadHisPage, new ClickCallBack() {
            @Override
            public void onClick(int flag, Object object) {
                srlLsBook.finishRefresh();
                srlLsBook.finishLoadMore();
                switch (flag) {
                    case 1:
                        BookReadHisMainBean data = (BookReadHisMainBean) object;
                        if (curBookReadHisPage == 1) {
                            bookReadHisList.clear();
                        }
                        bookReadHisList.addAll(data.getData().getData());
                        bookReadHisAdapter.setData(bookReadHisList);
                        break;
                    case 2:
                        String msg = (String) object;
                        ToastShowUtil.showToastCenter(SjActivity.this, msg);
                        break;
                }
            }
        });
    }

    private void getMhReadHis() {
        mPresenter.mhReadHis(true, 20, curMhReadHisPage, new ClickCallBack() {
            @Override
            public void onClick(int flag, Object object) {
                srlLsMh.finishLoadMore();
                srlLsMh.finishRefresh();
                switch (flag) {
                    case 1:
                        MhReadHisMainBean data = (MhReadHisMainBean) object;
                        if (curMhReadHisPage == 1) {
                            mhReadHisList.clear();
                        }
                        mhReadHisList.addAll(data.getData().getData());
                        mhReadHisAdapter.setData(mhReadHisList);
                        break;
                    case 2:
                        String msg = (String) object;
                        ToastShowUtil.showToastCenter(SjActivity.this, msg);
                        break;
                }
            }
        });
    }

    private void getDjSeeHis() {
        DJXSdk.service().getDramaHistory(curDjSeeHisPage, 20, new IDJXService.IDJXCallback<List<? extends DJXDrama>>() {
            @Override
            public void onSuccess(List<? extends DJXDrama> djxDramas, @Nullable DJXOthers djxOthers) {
                if (curDjSeeHisPage == 1) {
                    djHisList.clear();
                }
                djHisList.addAll(djxDramas);
                djSeeHisAdapter.setData(djHisList);
            }

            @Override
            public void onError(@NonNull DJXError djxError) {

            }
        });
//        mPresenter.djSeeJlList(true, 20, curDjSeeHisPage, new ClickCallBack() {
//            @Override
//            public void onClick(int flag, Object object) {
//                srlLsDj.finishLoadMore();
//                srlLsDj.finishRefresh();
//                switch (flag) {
//                    case 1:
//                        DjHisMainBean data = (DjHisMainBean) object;
//                        if (curDjSeeHisPage == 1) {
//                            djHisList.clear();
//                        }
//                        djHisList.addAll(data.getData().getData());
//                        djSeeHisAdapter.setData(djHisList);
//                        break;
//                    case 2:
//                        String msg = (String) object;
//                        ToastShowUtil.showToastCenter(SjActivity.this, msg);
//                        break;
//                }
//            }
//        });
    }

    private void plAddBookSj(String allIds) {
        mPresenter.plAddBookSj(true, allIds, new ClickCallBack() {
            @Override
            public void onClick(int flag, Object object) {
                switch (flag) {
                    case 1:
                        setTopTitle(1);
                        for (int i = 0; i < bookReadHisList.size(); i++) {
                            if (bookReadHisList.get(i).isSec()) {
                                if (bookReadHisList.get(i).getIs_bookshelf() != 1) {
                                    bookReadHisList.get(i).setIs_bookshelf(1);
                                }
                                bookReadHisList.get(i).setSec(false);
                                bookReadHisList.get(i).setShowCzType(false);
                            }
                        }
                        bookReadHisAdapter.setData(bookReadHisList);
                        break;
                    case 2:
                        String msg = (String) object;
                        ToastShowUtil.showToastCenter(SjActivity.this, msg);
                }
            }
        });
    }

    private void plDeleteBookHis(String allIds) {
        mPresenter.plDeleteBookHis(true, allIds, new ClickCallBack() {
            @Override
            public void onClick(int flag, Object object) {
                switch (flag) {
                    case 1:
                        setTopTitle(1);
                        curBookReadHisPage = 1;
                        getBookReadHis();
                        break;
                    case 2:
                        String msg = (String) object;
                        ToastShowUtil.showToastCenter(SjActivity.this, msg);
                }
            }
        });
    }

    private void plDeleteMhHis(String allIds) {
        mPresenter.plDeleteMhHis(true, allIds, new ClickCallBack() {
            @Override
            public void onClick(int flag, Object object) {
                switch (flag) {
                    case 1:
                        setTopTitle(1);
                        curMhReadHisPage = 1;
                        getMhReadHis();
                        break;
                    case 2:
                        String msg = (String) object;
                        ToastShowUtil.showToastCenter(SjActivity.this, msg);
                }
            }
        });
    }

    private void plDeleteDjJl(String allIds) {
        mPresenter.plDelDjJl(true, allIds, new ClickCallBack() {
            @Override
            public void onClick(int flag, Object object) {
                switch (flag) {
                    case 1:
                        setTopTitle(1);
                        curDjSeeHisPage = 1;
                        getDjSeeHis();
                        break;
                    case 2:
                        String msg = (String) object;
                        ToastShowUtil.showToastCenter(SjActivity.this, msg);
                }
            }
        });
    }

    private void getCjMhSd() {
        mPresenter.seeMhSd(true, 20, curCjMhSdPage, new ClickCallBack() {
            @Override
            public void onClick(int flag, Object object) {
                srlMhSd.finishRefresh();
                srlMhSd.finishLoadMore();
                switch (flag) {
                    case 1:
                        MhSdMainBean data = (MhSdMainBean) object;
                        if (curCjMhSdPage == 1) {
                            cjMhSdList.clear();
                        }
                        cjMhSdList.addAll(data.getData().getData());
                        cjMhSdAdapter.setData(cjMhSdList);
                        break;
                    case 2:
                        String msg = (String) object;
                        ToastShowUtil.showToastCenter(SjActivity.this, msg);
                        break;
                }
            }
        });
    }

    private void getScMhSd() {
        mPresenter.myScMhSd(true, 20, curScMhSdPage, new ClickCallBack() {
            @Override
            public void onClick(int flag, Object object) {
                srlScMhSd.finishRefresh();
                srlScMhSd.finishLoadMore();
                switch (flag) {
                    case 1:
                        MhSdScMainBean data = (MhSdScMainBean) object;
                        if (curScMhSdPage == 1) {
                            scMhSdList.clear();
                        }
                        scMhSdList.addAll(data.getData().getData());
                        scMhSdAdapter.setData(scMhSdList);
                        break;
                    case 2:
                        String msg = (String) object;
                        ToastShowUtil.showToastCenter(SjActivity.this, msg);
                        break;
                }
            }
        });
    }

    private void initClick() {
        llSjTab.setOnClickListener(view -> {
            setTopTab(1);
            setSjType(1);
        });
        llLsTab.setOnClickListener(view -> {
            curBookReadHisPage = 1;
            setTopTab(2);
            setLsType(1);
            getBookReadHis();
        });
        llMhSdTab.setOnClickListener(view -> {
            setTopTab(3);
            setMhSdTab(1);
            curCjMhSdPage = 1;
            getCjMhSd();
        });
        tvMhSdCjTab.setOnClickListener(view -> {
            setMhSdTab(1);
            curCjMhSdPage = 1;
            getCjMhSd();
        });
        tvMhSdScTab.setOnClickListener(view -> {
            setMhSdTab(2);
            curScMhSdPage = 1;
            getScMhSd();
        });
        ivSearch.setOnClickListener(view -> {
            Intent intent = new Intent(SjActivity.this, SearchActivity.class);
            startActivity(intent);
        });
        tvSjBook.setOnClickListener(view -> {
            setSjType(1);
            getBookSjList();
        });
        tvSjMh.setOnClickListener(view -> {
            setSjType(2);
            getMhSjList();
        });
        tvSjDj.setOnClickListener(view -> {
            setSjType(3);
            getZjSjList();
        });
        tvLsBook.setOnClickListener(view -> {
            curBookReadHisPage = 1;
            setLsType(1);
            getBookReadHis();
        });
        tvLsMh.setOnClickListener(view -> {
            setLsType(2);
            curMhReadHisPage = 1;
            getMhReadHis();
        });
        tvLsDj.setOnClickListener(view -> {
            setLsType(3);
            curDjSeeHisPage = 1;
            getDjSeeHis();
        });
        ivXg.setOnClickListener(view -> {
            setTopTitle(2);
            if (lsSubTypeTag == 1) {
                llAddSj.setVisibility(View.VISIBLE);
                //历史-小说 修改
                if (bookReadHisList != null && bookReadHisList.size() > 0) {
                    for (int i = 0; i < bookReadHisList.size(); i++) {
                        bookReadHisList.get(i).setShowCzType(true);
                    }
                    bookReadHisAdapter.setData(bookReadHisList);
                }
            } else if (lsSubTypeTag == 2) {
                llAddSj.setVisibility(View.GONE);
                if (mhReadHisList != null && mhReadHisList.size() > 0) {
                    for (int i = 0; i < mhReadHisList.size(); i++) {
                        mhReadHisList.get(i).setShowCzType(true);
                    }
                    mhReadHisAdapter.setData(mhReadHisList);
                }
            } else if (lsSubTypeTag == 3) {
                llAddSj.setVisibility(View.GONE);
                if (djHisList != null && djHisList.size() > 0) {
                    tvCount.setText("共选择" + djHisList.size() + "个");
                }
            }
        });
        tvQx.setOnClickListener(view -> {
            //全选
            if (lsSubTypeTag == 1) {
                if (bookReadHisList != null && bookReadHisList.size() > 0) {
                    for (int i = 0; i < bookReadHisList.size(); i++) {
                        bookReadHisList.get(i).setSec(true);
                    }
                    bookReadHisAdapter.setData(bookReadHisList);
                    tvCount.setText("共选择" + bookReadHisList.size() + "个");
                }
            } else if (lsSubTypeTag == 2) {
                if (mhReadHisList != null && mhReadHisList.size() > 0) {
                    for (int i = 0; i < mhReadHisList.size(); i++) {
                        mhReadHisList.get(i).setSec(true);
                    }
                    mhReadHisAdapter.setData(mhReadHisList);
                    tvCount.setText("共选择" + mhReadHisList.size() + "个");
                }
            } else if (lsSubTypeTag == 3) {
                if (djHisList != null && djHisList.size() > 0) {
                    tvCount.setText("共选择" + djHisList.size() + "个");
                }
            }
        });
        tvDone.setOnClickListener(view -> {
            //完成
            setTopTitle(1);
            if (lsSubTypeTag == 1) {
                //历史-小说 修改
                if (bookReadHisList != null && bookReadHisList.size() > 0) {
                    for (int i = 0; i < bookReadHisList.size(); i++) {
                        bookReadHisList.get(i).setShowCzType(false);
                        bookReadHisList.get(i).setSec(false);
                    }
                    bookReadHisAdapter.setData(bookReadHisList);
                }
            } else if (lsSubTypeTag == 2) {
                if (mhReadHisList != null && mhReadHisList.size() > 0) {
                    for (int i = 0; i < mhReadHisList.size(); i++) {
                        mhReadHisList.get(i).setShowCzType(false);
                        mhReadHisList.get(i).setSec(false);
                    }
                    mhReadHisAdapter.setData(mhReadHisList);
                }
            } else if (lsSubTypeTag == 3) {
//                if (djHisList != null && djHisList.size() > 0) {
//                    for (int i = 0; i < djHisList.size(); i++) {
//                        djHisList.get(i).setShowCzType(false);
//                        djHisList.get(i).setSec(false);
//                    }
//                    djSeeHisAdapter.setData(djHisList);
//                }
            }
        });
        llAddSj.setOnClickListener(view -> {
            if (lsSubTypeTag == 1) {
                int secCount = 0;
                String bookIds = "";
                if (bookReadHisList != null && bookReadHisList.size() > 0) {
                    for (int i = 0; i < bookReadHisList.size(); i++) {
                        if (bookReadHisList.get(i).isSec()) {
                            if (bookReadHisList.get(i).getIs_bookshelf() != 1) {
                                secCount = secCount + 1;
                                bookIds = bookIds + "," + bookReadHisList.get(i).getNovel_id();
                            }
                        }
                    }
                    if (secCount == 0) {
                        ToastShowUtil.showToastCenter(SjActivity.this, "请选择小说");
                    } else {
                        plAddBookSj(BusinessUtils.getAllIds(bookIds));
                    }
                }
            }
        });
        llDelete.setOnClickListener(view -> {
            if (lsSubTypeTag == 1) {
                int secCount = 0;
                String bookIds = "";
                if (bookReadHisList != null && bookReadHisList.size() > 0) {
                    for (int i = 0; i < bookReadHisList.size(); i++) {
                        if (bookReadHisList.get(i).isSec()) {
                            secCount = secCount + 1;
                            bookIds = bookIds + "," + bookReadHisList.get(i).getId();
                        }
                    }
                    if (secCount == 0) {
                        ToastShowUtil.showToastCenter(SjActivity.this, "请选择小说");
                    } else {
                        plDeleteBookHis(BusinessUtils.getAllIds(bookIds));
                    }
                }
            } else if (lsSubTypeTag == 2) {
                int secCount = 0;
                String mhIds = "";
                if (mhReadHisList != null && mhReadHisList.size() > 0) {
                    for (int i = 0; i < mhReadHisList.size(); i++) {
                        if (mhReadHisList.get(i).isSec()) {
                            secCount = secCount + 1;
                            mhIds = mhIds + "," + mhReadHisList.get(i).getId();
                        }
                    }
                    if (secCount == 0) {
                        ToastShowUtil.showToastCenter(SjActivity.this, "请选择漫画");
                    } else {
                        plDeleteMhHis(BusinessUtils.getAllIds(mhIds));
                    }
                }
            } else if (lsSubTypeTag == 3) {
                int secCount = 0;
                String mhIds = "";
//                if (djHisList != null && djHisList.size() > 0) {
//                    for (int i = 0; i < djHisList.size(); i++) {
//                        if (djHisList.get(i).isSec()) {
//                            secCount = secCount + 1;
//                            mhIds = mhIds + "," + djHisList.get(i).getId();
//                        }
//                    }
//                    if (secCount == 0) {
//                        ToastShowUtil.showToastCenter(SjActivity.this, "请选择短剧");
//                    } else {
//                        plDeleteDjJl(BusinessUtils.getAllIds(mhIds));
//                    }
//                }
                DJXSdk.service().clearDramaHistory(new IDJXService.IDJXCallback<List<? extends DJXDrama>>() {
                    @Override
                    public void onSuccess(List<? extends DJXDrama> djxDramas, @Nullable DJXOthers djxOthers) {
                        ToastShowUtil.showToastCenter(SjActivity.this,"已删除");
                        setTopTitle(1);
                        getDjSeeHis();
                    }

                    @Override
                    public void onError(@NonNull DJXError djxError) {
                        ToastShowUtil.showToastCenter(SjActivity.this,"删除失败");
                    }
                });
            }
        });
        ivMhSdCj.setOnClickListener(view -> {
            Intent intent = new Intent(SjActivity.this, CjMhSdActivity.class);
            startActivityForResult(intent, 1001);
        });
        llTab1.setOnClickListener(view -> {
            Intent intent = new Intent(SjActivity.this, HomeActivity.class);
            startActivity(intent);
            finish();
        });
        llTab3.setOnClickListener(view -> {
            Intent intent = new Intent(SjActivity.this, TaskGcActivity.class);
            startActivity(intent);
            finish();
        });
        llTab4.setOnClickListener(view -> {
            Intent intent = new Intent(SjActivity.this, MyActivity.class);
            startActivity(intent);
            finish();
        });
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == RESULT_OK) {
            switch (requestCode) {
                case 1001:
                    setMhSdTab(1);
                    curCjMhSdPage = 1;
                    getCjMhSd();
                    break;
            }
        }
    }
}